package com.sgb.kjwl.view.ui.quickentry;

import android.content.Context;
import android.view.View;

import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ItemQuickEntryViewBinding;
import com.swgk.core.BR;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public class QuickEntryAdapter extends BaseRecycleAdapter<QuickEntryEntity> {

    private QuickEntryClickListener listener;

    public QuickEntryAdapter(Context context, List<QuickEntryEntity> data) {
        super(context, R.layout.item_quick_entry_view, data);
    }

    @Override
    public void convert(ItemViewHolder holder, QuickEntryEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        ItemQuickEntryViewBinding binding = (ItemQuickEntryViewBinding) holder.getmBinding();
        binding.tvName.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener != null)
                    listener.onItemClick(entity);
            }
        });
    }

    public void setListener(QuickEntryClickListener listener) {
        this.listener = listener;
    }
}
